<html>
<head>
    <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>

    <title>微信支付样例-支付</title>

</head>
<body>
<script src="http://libs.baidu.com/jquery/2.0.0/jquery.min.js"></script>
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<br/>
<font color="#9ACD32"><b>该笔订单支付金额为<span style="color:#f00;font-size:50px">1分</span>钱</b></font><br/><br/>
<div align="center">
    <button style="width:210px; height:50px; border-radius: 15px;background-color:#FE6714;
    border:0px #FE6714 solid; cursor: pointer;  color:white;  font-size:16px;" type="button"
            onclick="callpay()" >立即支付</button>
</div>
<div id="pay" onclick="aaa()">123</div>
<script type="text/javascript">

    $(function () {
        var shareTitle = "更多优惠，尽在聚惠";
        var shareDesc = "大回馈，花少钱享优质生活，更多优惠商品，就等你喊朋友一起来选！";
        var currentLink ='http://yun.youpilive.com';
        var shareImgUrl = "http://yun.youpilive.com/static/layuimini/images/logo.png";
        var shareLink = currentLink ;
        var shareGid = "";
        $.ajax({
            type: "post",
            url:'http://yun.8a1.top/api/WeChat/getSignPackage',
            data:{
                url:currentLink,
            },
            success: function (response) {
                // return false
                console.log('request success');

                wx.config({
                    debug: true,
                    appId: response.appId,
                    timestamp: response.timestamp,
                    nonceStr: response.nonceStr,
                    signature: response.signature,
                    jsApiList: [
                        'updateAppMessageShareData',
                        'updateTimelineShareData',
                    ]
                });
                setTimeout(function () {
                    console.log('wx config');

                    console.log('wx ready');
                    wx.ready(function () {
                        //分享给朋友

                        // //分享到朋友圈
                        // wx.onMenuShareTimeline({
                        //     title: shareTitle,
                        //     desc: shareDesc,
                        //     link: shareLink,
                        //     imgUrl: shareImgUrl,
                        //     success: function (res) {
                        //         shared(shareLink, "Timeline", shareGid);
                        //     },
                        //     fail: function (res) {
                        //         alert(JSON.stringify(res));
                        //     }
                        // });
                        // //分享到QQ
                        // wx.onMenuShareQQ({
                        //     title: shareTitle,
                        //     desc: shareDesc,
                        //     link: shareLink,
                        //     imgUrl: shareImgUrl,
                        //     success: function (res) {
                        //         shared(shareLink, "QQ", shareGid);
                        //     },
                        //     fail: function (res) {
                        //         alert(JSON.stringify(res));
                        //     }
                        // });
                        // //分享到腾讯QQ
                        // wx.onMenuShareWeibo({
                        //     title: shareTitle,
                        //     desc: shareDesc,
                        //     link: shareLink,
                        //     imgUrl: shareImgUrl,
                        //     success: function (res) {
                        //         shared(shareLink, "Weibo", shareGid);
                        //     },
                        //     fail: function (res) {
                        //         alert(JSON.stringify(res));
                        //     }
                        // });
                        // //分享到QZone
                        // wx.onMenuShareQZone({
                        //     title: shareTitle,
                        //     desc: shareDesc,
                        //     link: shareLink,
                        //     imgUrl: shareImgUrl,
                        //     success: function (res) {
                        //         shared(shareLink, "QZone", shareGid);
                        //     },
                        //     fail: function (res) {
                        //         alert(JSON.stringify(res));
                        //     }
                        // });
                    });
                },3000)
                console.log('success');

                // function shared(url, type, gid){
                //     var rUrl = basePath + "/share/add?type=" + type + "&url=" + encodeURI(url);
                //     if(!!gid) {
                //         rUrl += "&gid=" + gid;
                //     }
                //     $.ajax({
                //         type: "GET",
                //         url: rUrl,
                //         dataType: "json",
                //         success: function(rs){
                //             //alert("分享成功");
                //         }
                //     });
                // }
            }
        });

    })

    function aaa() {
        wx.onMenuShareAppMessage({
            title: shareTitle,
            desc: shareDesc,
            link: shareLink,
            imgUrl: shareImgUrl,
            success: function (res) {
                console.log(res);
                shared(shareLink, "friend", shareGid);
            },
            fail: function (res) {
                console.log(res);
                alert(JSON.stringify(res));
            }
        });
    }

</script>

</body>
</html>